package com.ruoyi.camera.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.camera.domain.AimpCamera;
import com.ruoyi.camera.service.IAimpCameraService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 摄像机Controller
 * 
 * @author ruoyi
 * @date 2022-06-02
 */
@RestController
@RequestMapping("/equipment/camera")
public class AimpCameraController extends BaseController
{
    @Autowired
    private IAimpCameraService aimpCameraService;

    /**
     * 查询摄像机列表
     */
    @PreAuthorize("@ss.hasPermi('equipment:camera:list')")
    @GetMapping("/list")
    public TableDataInfo list(AimpCamera aimpCamera)
    {
        startPage();
        List<AimpCamera> list = aimpCameraService.selectAimpCameraList(aimpCamera);
        return getDataTable(list);
    }

    /**
     * 导出摄像机列表
     */
    @PreAuthorize("@ss.hasPermi('equipment:camera:export')")
    @Log(title = "摄像机", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AimpCamera aimpCamera)
    {
        List<AimpCamera> list = aimpCameraService.selectAimpCameraList(aimpCamera);
        ExcelUtil<AimpCamera> util = new ExcelUtil<AimpCamera>(AimpCamera.class);
        util.exportExcel(response, list, "摄像机数据");
    }

    /**
     * 获取摄像机详细信息
     */
    @PreAuthorize("@ss.hasPermi('equipment:camera:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(aimpCameraService.selectAimpCameraById(id));
    }

    /**
     * 新增摄像机
     */
    @PreAuthorize("@ss.hasPermi('equipment:camera:add')")
    @Log(title = "摄像机", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AimpCamera aimpCamera)
    {
        return toAjax(aimpCameraService.insertAimpCamera(aimpCamera));
    }

    /**
     * 修改摄像机
     */
    @PreAuthorize("@ss.hasPermi('equipment:camera:edit')")
    @Log(title = "摄像机", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AimpCamera aimpCamera)
    {
        return toAjax(aimpCameraService.updateAimpCamera(aimpCamera));
    }

    /**
     * 删除摄像机
     */
    @PreAuthorize("@ss.hasPermi('equipment:camera:remove')")
    @Log(title = "摄像机", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(aimpCameraService.deleteAimpCameraByIds(ids));
    }
}
